package com.bigShen.mybatis.session;


import com.bigShen.mybatis.conf.ConfigurationShen;
import com.bigShen.mybatis.exector.Executor;
import com.bigShen.mybatis.exector.SimpleExecutorShen;
import com.bigShen.mybatis.proxy.MapperProxyShen;

import java.lang.reflect.Proxy;

/**
 * @Author eddy.shen
 * @Date 2018/12/8 21:03
 **/
public class SqlSessionShen {

    private ConfigurationShen configuration = new ConfigurationShen();

    private Executor executor = new SimpleExecutorShen();


    public ConfigurationShen getConfiguration() {
        return configuration;
    }

    public Executor getExecutor() {
        return executor;
    }

    public <T> T getMapper(Class<T> mapperClass) {

        return (T) Proxy.newProxyInstance(this.getClass().getClassLoader(),
                new Class[]{mapperClass}, new MapperProxyShen(this, mapperClass));

    }


}
